#include <iostream.h>
#include <conio.h>
#include "matrix.h"

void matrix::multiply(matrix m1, matrix m2)
{
	if(m1.n!=m2.m)
	{
		cout<<"matrix multiplication is not possible";
	}
	else
	{
		for(int i=0;i<m1.m;i++)
		{
			for(int j=0;j<m2.n;j++)
			{
				result[i][j]=0;
				for(int k=0;k<m1.n;k++)
				{
					result[i][j] = a[i][j] +( m1.a[i][k]*m2.b[k][j]);
					m=m1.m;
					n=m2.n;
				}
			}
		}
	}
}

void matrix::addition(matrix m1 , matrix m2)
{
	for(int i=0;i<m1.m;i++)
		{
			for(int j=0;j<m2.n;j++)
			{
				result[i][j]=0;
				for(int k=0;k<m1.n;k++)
				{
					result[i][j] = a[i][j] + b[i][j]);
					m=m1.m;
					n=m2.n;
				}
			}
		}
}

void matrix::subtract(matrix m1, matrix m2)
{
	for(int i=0;i<m1.m;i++)
		{
			for(int j=0;j<m2.n;j++)
			{
				result[i][j]=0;
				for(int k=0;k<m1.n;k++)
				{
					result[i][j] = a[i][j] + b[i][j]);
					m=m1.m;
					n=m2.n;
				}
			}
		}

}